<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.tjsinfo.tjsoa.system.vo.User"%>
<%@page import="com.tjsinfo.tjsoa.messageImportant.vo.MessageImportantIncept"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>"/>

		<title>粮油集团办公自动化协作平台</title>
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
		<link href="<%=basePath%>style/txlz7.css" rel="stylesheet" type="text/css" id="txlz7"/>
<link rel="stylesheet" type="text/css" href="<%=basePath %>ajaxFramework/ext-2.1/resources/css/ext-all.css" />
<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/ext-all.js"></script>
<script type="text/javascript" src="<%=basePath %>ajaxFramework/jQuery/jquery.js"></script>
		<style type="text/css">
td {
	font: 12px/ 170% "宋体", "新宋体", "黑体";
	color: #000
}

th {
	font: 12px/ 170% "宋体", "新宋体", "黑体";
	color: #000
}

.trBgColor {
	background-color: #A4D7E8;
	cursor: hand;
}

.black_overlays {
	display: none;
	position: absolute;
	top: 0%;
	left: 0%;
	width: 100%;
	height: 100%;
	background-color: #C1EBFC;
	z-index: 1002;
	-moz-opacity: 0.8;
	opacity: .80;
	filter: alpha(opacity =   30);
}

.insertGroup {
	display: none;
	position: absolute;
	border: 1px solid #FFF;
	border-bottom: none;
	z-index: 1002;
	overflow: auto;
}

.window {
	DISPLAY: none;
	LEFT: 300px;
	OVERFLOW: hidden;
	WIDTH: 500px;
	POSITION: absolute;
	TOP: 100px;
	HEIGHT: 200px
}

.windowTop {
	BACKGROUND-POSITION: right top;
	BACKGROUND-IMAGE:
		url(<%=basePath%>/images/window_top_end.png);
	OVERFLOW: hidden;
	CURSOR: move;
	BACKGROUND-REPEAT: no-repeat;
	POSITION: relative;
	HEIGHT: 30px
}

.windowTopContent {
	BACKGROUND-POSITION: left top;
	FONT-WEIGHT: bold;
	FONT-SIZE: 14px;
	BACKGROUND-IMAGE:
		url(<%=basePath%>/images/window_top_start.png);
	OVERFLOW: hidden;
	COLOR: #206D85;
	TEXT-INDENT: 10px;
	LINE-HEIGHT: 30px;
	MARGIN-RIGHT: 13px;
	BACKGROUND-REPEAT: no-repeat;
	FONT-FAMILY: Arial, Helvetica, sans-serif;
	HEIGHT: 30px
}

#windowBottom {
	BACKGROUND-POSITION: right bottom;
	BACKGROUND-IMAGE:
		url(<%=basePath%>/images/window_bottom_end.png);
	BACKGROUND-REPEAT: no-repeat;
	POSITION: relative;
	HEIGHT: 370px
}

.windowBottomContent {
	BACKGROUND-POSITION: left bottom;
	BACKGROUND-IMAGE:
		url(<%=basePath%>/images/window_bottom_start.png);
	MARGIN-RIGHT: 13px;
	BACKGROUND-REPEAT: no-repeat;
	POSITION: relative;
	HEIGHT: 370px
}

.windowResize {
	RIGHT: 3px;
	CURSOR: se-resize;
	BOTTOM: 5px;
	POSITION: absolute
}

#windowClose {
	RIGHT: 10px;
	CURSOR: pointer;
	POSITION: absolute;
	TOP: 10px
}

.windowContent {
	BORDER-RIGHT: #6caf00 1px solid;
	BORDER-TOP: #6caf00 1px solid;
	FONT-SIZE: 11px;
	LEFT: 10px;
	OVERFLOW: auto;
	BORDER-LEFT: #6caf00 1px solid;
	WIDTH: 475px;
	MARGIN-RIGHT: 15px;
	BORDER-BOTTOM: #6caf00 1px solid;
	FONT-FAMILY: Arial, Helvetica, sans-serif;
	POSITION: absolute;
	TOP: 30px;
	HEIGHT: 150px;
	BACKGROUND-COLOR: #fff
}

.lan01 {
	background: url(<%=basePath%>images/lanbg01.gif) no-repeat 0 0;
	width: 6px;
	height: 24px;
}

.lan02 {
	background: url(<%=basePath%>images/lanbg02.gif) repeat-x;
	width: 99%;
	height: 24px;
}

.lan03 {
	background: url(<%=basePath%>images/lanbg03.gif) no-repeat;
	width: 8px;
	height: 24px;
}

.cha {
	padding-top: 3px;
}
		.daohang {
		    background-image: url(<%=basePath%>images/ju.gif) !important;
		}
</style>
		<script type='text/javascript'
			src='<%=basePath%>dwr/interface/MessageImportantInceptBo.js'></script>
		<script type='text/javascript'
			src='<%=basePath%>dwr/interface/OfficeResourceRequestBo.js'></script>
		<script type='text/javascript' src="<%=basePath%>dwr/engine.js"></script>
		<script type='text/javascript' src="<%=basePath%>dwr/util.js"></script>
		<%
			List<MessageImportantIncept> list = (List<MessageImportantIncept>) request
					.getAttribute("list");
			int pagecount = 0;
			if (list.size() != 0) {
				pagecount = list.size();
			}
		%>
		<script type="text/javascript">
	 	function beizhuxian(remark,i,state,id,receiveuser){
	 		var pageselect = document.getElementById('page'); 
	 		pageselect.style.display = "none";
			var windowdiv = document.getElementById("windowdiv");
			if(windowdiv.style.display != 'none') {
				beizhuguan('true');
			}
			var j = parseInt(i)+2;
			if(state='0'){
				document.getElementById('mytable').rows(j).cells(3).innerHTML='已阅';
				MessageImportantInceptBo.update(id,receiveuser,{callback:function(str){document.getElementById('mytable').rows(j).cells(2).innerHTML=str;}});
			}
			if(windowdiv.style.display == 'none') {
				document.getElementById("item_"+i+"").className="trBgColor";
				document.getElementById("item_"+i+"").onmouseout = '';
				var beizhudiv = document.getElementById("beizhuid"+i+"");
				var Objxy=getXY(beizhudiv);
				
				var topzhu = windowdiv.style.top;
				var h = document.body.offsetHeight;
				if(h-Objxy.y>200){
					windowdiv.style.top = Objxy.y+23;
				}else{
					windowdiv.style.top = Objxy.y-200;
				}
				windowdiv.style.left = Objxy.x-500;
				document.getElementById('remarkdiv').innerHTML=remark;
				document.getElementById('beizhuid').value=i;
				windowdiv.style.display = 'block';
			}
		}
	
		
		function beizhuguan(bl){
			if(bl==null){
			var pageselect = document.getElementById('page');
	 		pageselect.style.display = "block";
	 		}
			var i = document.getElementById('beizhuid').value;
			
			var beizhudiv = document.getElementById("beizhuid"+i+"");
			var Objxy=getXY(beizhudiv);
			
			var b = document.getElementById('item_'+i+'');
			b.onmouseout=function(){this.className='';};
			document.getElementById("item_"+i+"").className=null;
			var windowOpendiv = document.getElementById("windowdiv");
			windowdiv.style.display = 'none';
		}
		
		function getXY(Obj) {
			var sumTop = 0, sumLeft = 0;
			while(Obj != document.body){
			sumLeft += Obj.offsetLeft;sumTop += Obj.offsetTop;Obj = Obj.offsetParent;
			} 
			return {x:sumLeft, y:sumTop};
		} 
		
		function xiazai(id,receiveuser,xiazaiurl){
			MessageImportantInceptBo.update(id,receiveuser,{
				callback:function(str){
					window.location.href='<%=basePath %>tjsinfo/tjsoa/messageImportant/receiveMessage.do?id='+xiazaiurl;
				}
				});
		}
	 </script>
		<script language="JavaScript" type="text/javascript">//最大数据量
	 	window.onload = function(){
		initpage(1);
			var tb = new Ext.Toolbar(
				{
					height:25
				}
			);
		
		    tb.render('menu');
			tb.add(
		    {
		            text:'返回主页',
		            iconCls: 'daohang',
		        	handler: function(){
		        		location.href="<%=basePath%>tjsinfo/tjsoa/system/main.do";
					}
		    }
		    );
		
		}
	 	
var total="<%=pagecount%>";
//每页的显示量
var pagesize="17";
//一共有多少页


var pagenum=Math.ceil(total/pagesize);
//生成导航
var nowpage = 1;
function initpage(nowpage){
var pagenav='<a>共'+pagenum+'页,当前为'+nowpage+'页</a>,<a href="javaScript:goToPage(1);">第一页</a>,<a href="javaScript:up('+ nowpage+');">上一页</a> ';
pagenav += '<select onchange="goToPage(this.value);" id="pageselect">';
for(i=1;i<=pagenum;i++){
	if(i==nowpage){
		pagenav += '<option value="'+i+'" selected="selected">'+i+'</option>';
	}else{
		pagenav += '<option value="'+i+'">'+i+'</option>';
	}
}
pagenav += '</select>';
pagenav += '<a href="javaScript:down('+ nowpage+');">下一页</a>,<a href="javaScript:goToPage('+ pagenum+');">最后一页</a>';
if(pagenum != 0){
document.getElementById('page').innerHTML=pagenav;
}
}
//翻页
var deletei = '';
function goToPage(page){
var z = deletei.split(",");
var start=(page-1)*pagesize;
var max=page*pagesize;
var bl = true;
for(vs=0;vs<total;vs++){
	var obj=document.getElementById('item_' + vs);
	obj.style.display="none";
	bl = true;
}
if(max>total)max=total;
for(v=start;v<max;v++){
	var obj=document.getElementById('item_' + v);
	for(var j = 0;j<z.length;j++){
		if(z[j] != '' && z[j] == v){
			bl=false;
		}
	}
	if(deletei == '')bl=true;
	if(bl)obj.style.display="block"; else obj.style.display="none";
}
initpage(page);
}
//上一页


function up(nowpage){
if(nowpage>1)goToPage((nowpage-1));
}
//下一页


function down(nowpage){
if(nowpage<pagenum)goToPage((nowpage+1));
}
		function init(){
			window.parent.frames.mainFrame.location.reload();
		}
		
		function fasongpaixu(){
			Ext.MessageBox.show({
		        title: '提示框',
		        msg:'选择发送日期排序方式',
		        width: 300,
		        buttons: { ok: "升序", no:"降序",cancel:'关闭' },  
		        fn: function(btn, text) {
		       		if (btn == 'ok') {
		       			window.location.href = '<%=basePath%>tjsinfo/tjsoa/messageImportant/loginReceiveMain.do?orderType=fasong&order=asc';
		            }else if(btn == 'no'){
		       			window.location.href = '<%=basePath%>tjsinfo/tjsoa/messageImportant/loginReceiveMain.do?orderType=fasong&order=desc';
		            }
		        }
		    });
		}
		
		function chakanpaixu(){
			Ext.MessageBox.show({
		        title: '提示框',
		        msg:'选择查看日期排序方式',
		        width: 300,
		        buttons: { ok: "升序", no:"降序",cancel:'关闭' },  
		        fn: function(btn, text) {
		       		if (btn == 'ok') {
		       			window.location.href = '<%=basePath%>tjsinfo/tjsoa/messageImportant/loginReceiveMain.do?orderType=datetime&order=asc';
		            }else if(btn == 'no'){
		       			window.location.href = '<%=basePath%>tjsinfo/tjsoa/messageImportant/loginReceiveMain.do?orderType=datetime&order=desc';
		            }
		        }
		    });
		}
</script>
	</head>

	<body>
		<div id="right" style="z-index: 19; height: 98%">
			<div id="menu" style="padding-top: 4px;"></div>
			<table width="100%" border="0" cellspacing="0" cellpadding="0"
				height="100%">
				<tr>
					<td width="100%" valign="top" height="100%">
						<div class="contab" style="height: 90%; width: 100%">
							<table class="p_06" width="100%" border="0" cellspacing="0"
								id="mytable">
								<tr align="center" />
								<tr>
									<th width="20%" style="text-align: center;">
										发送日期(<a href="javascript:fasongpaixu();">排序</a>)
									</th>
									<th width="20%" style="text-align: center;">
										发送人
									</th>
									<th width="20%" style="text-align: center;">
										查看日期(<a href="javascript:chakanpaixu();">排序</a>)
									</th>
									<th width="20%" style="text-align: center;">
										状态
									</th>
									<th width="20%" style="text-align: center;">
										操作
									</th>
								</tr>
								<%
									int i = 0;
									SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
									for (MessageImportantIncept incept : list) {
										String id = incept.getId().toString();
										String sendtime = sdf.format(incept.getMessageImportantMain()
										.getDatetime());
										String receivetime = "&nbsp;";
										if (incept.getDatetime() != null) {
											receivetime = sdf.format(incept.getDatetime());
										}
										String sendUser = incept.getMessageImportantMain().getSendUsername();
										String info = incept.getMessageImportantMain().getInfo();
										String state = incept.getState().toString();
										String receiveuser = incept.getReceiveUsername();
								%>
								<tr onmouseover='this.className="trBgColor"'
									onmouseout='this.className=""' id="item_<%=i%>">
									<td onclick="javascript:beizhuxian('<%=info.replace("<br/>", " ")%>','<%=i%>','<%=state%>','<%=id%>','<%=receiveuser %>');"><%=sendtime%></td>
									<td onclick="javascript:beizhuxian('<%=info.replace("<br/>", " ")%>','<%=i%>','<%=state%>','<%=id%>','<%=receiveuser %>');"><%=sendUser%></td>
									<td onclick="javascript:beizhuxian('<%=info.replace("<br/>", " ")%>','<%=i%>','<%=state%>','<%=id%>','<%=receiveuser %>');"><%=receivetime%></td>
									<td id="a" onclick="javascript:beizhuxian('<%=info.replace("<br/>", " ")%>','<%=i%>','<%=state%>','<%=id%>','<%=receiveuser %>');">
										<%
										if ("0".equals(state)) {
										%>
										<a style="color: red">待阅</a>
										<%
										} else {
										%>
										已阅
										<%
										}
										%>
									</td>
									<td id="beizhuid<%=i%>">
										<a
											onclick="javascript:beizhuxian('<%=info.replace("<br/>", " ")%>','<%=i%>','<%=state%>','<%=id%>','<%=receiveuser %>');">查看内容</a>
										<%
										if ("yes".equals(incept.getMessageImportantMain().getFileUpload())) {
										%>
											<a href="javascript:xiazai('<%=id%>','<%=receiveuser %>','<%=incept.getMessageImportantMain().getId()%>');">文件下载</a>
										<%
										}
										%>
									</td>
								</tr>
								<%
									i++;
									}
								%>
								<tr align="center">
									<td colspan="7">
										<div class="pages" id="page">
										</div>
									</td>
								</tr>
							</table>
						</div>
					</td>
				</tr>
			</table>
		</div>
		<div class="insertGroup" id="shaodeng">
			<table width="478" border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td height="24" align="left">
						<b>请求正在处理中,请稍候....</b>
					</td>
				</tr>
			</table>
		</div>
		<div id="blackdiv" class="black_overlays">
			<iframe
				style="width: 100%; height: 100%; filter: alpha(opacity =   0); -moz-opacity: 0"></iframe>
		</div>
		<input type="hidden" id="beizhuid" />
		<div id="windowdiv" class="window" style="display: none">
			<div id="windowTop" class="windowTop">
				<div id="windowTopContent" class="windowTopContent">
					信息内容
				</div>
				<img id="windowClose"
					src="<%=basePath%>/images/window_close.jpg"
					onclick="beizhuguan();" class="windowClose" />
			</div>
			<div id="windowBottom" class="windowBottom">
				<div id="windowBottomContent" class="windowBottomContent"
					style="width: 500"></div>
			</div>
			<div id="windowContent" style="background: #D9E8F1;"
				class="windowContent">
				<div style="padding-top: 20px; padding-left: 20px; width: 90%"
					id="remarkdiv">
				</div>
			</div>
			<img id="windowResize"
				src="<%=basePath%>/images/window_resize.gif"
				class="windowResize" />
		</div>
	<script>
		for(vs=1;vs<total;vs++){
			var obj=document.getElementById('item_' + vs);
			obj.style.display="none";
			for(v=1;v<pagesize;v++){
				if(vs==v){
					var obj=document.getElementById('item_' + vs);
					obj.style.display="block";
				}
			}
		}
	</script>
	</body>
</html>
